package com.jarvis.plugin.dataredis.prefix.config;

import com.jarvis.plugin.dataredis.prefix.interceptor.DataredisPrefixInterceptor;
import com.jarvis.springboot.starter.guice.SpringModule;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author xuxukang
 * @date 2019-07-05 15:36
 */
@Component
public class DataredisPrefixModule extends SpringModule {
	
	@Autowired
	public DataredisPrefixModule(ListableBeanFactory listableBeanFactory) {
		super(listableBeanFactory);
	}
	
	@Override
	protected void configure() {
		super.configure();
		
		bind(DataredisPrefixProperty.class)
				.toInstance(listableBeanFactory.getBean(DataredisPrefixProperty.class));
		bind(Environment.class)
				.toInstance(listableBeanFactory.getBean(Environment.class));
		requestStaticInjection(DataredisPrefixInterceptor.class);
	}
}
